<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // console.log(typeof '');
      const isNum = (val) => {
        if (typeof val === "string") {
          return Number(val);
        }
        return 0;
      };

      const fn = (s1, s2) => {
        s1 = s1.split("").reverse();
        s2 = s2.split("").reverse();
        console.log(s1);
        let len1 = s1.length;
        let len2 = s2.length;
        let flag = 0;
        const stack = [];
        for (let i = 0; i < Math.max(len1, len2); i++) {
          let sum = isNum(s1[i]) + isNum(s2[i]) + flag;
          flag = sum > 10 ? 1 : 0;
          stack.push(sum % 10);
        }
        // 计算完
        if (flag === 1) {
          stack.push(1);
        }
        return stack.reverse().join("");
      };
      const res = fn("9999999999999000", "123456789999999999");
      console.log(res);
    </script>
  </body>
</html>
